home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / Ant Movie Catalog 3.5.0.2 / amc_install.exe / {app} / Scripts / Amazon Image (FR).ifs < prev    next >
Text File  |  2005-05-23  |  8KB  |  249 lines

  1. (***************************************************
  2.  
  3. Ant Movie Catalog importation script
  4. www.antp.be/software/moviecatalog/
  5.  
  6. [Infos]
  7. Authors=ScorEpioN
  8. Title=Amazon.fr (Image Only)
  9. Description=Grande Image et titre Amazon.fr
  10. Site=http://www.amazon.fr
  11. Language=FR
  12. Version=11 du 23/05/2005
  13. Requires=3.5
  14. Comments=Ce script nΘcessite le fichier ScorEpioNCommonScript.pas|.==.| :   ' ( ( ( ( /\ |  "==()))))):     ⌐ ScorEpioN ⌐|       ( ( ( ( \_/
  15. License=This program is free software; you can redistribute it and/or modify it under the  terms of the GNU General Public License as published by the Free Software Foundation;  either version 2 of the License, or (at your option) any later version. |
  16. GetInfo=1
  17.  
  18. [Options]
  19. Mise α jour=1|1|0=Oui|1=Non
  20. Type de Lancement=0|0|0=Demande le titre avant de lancer le script|1=Ne demande pas le titre avant de lancer le script|2=Cherche la meilleur image sans confirmation
  21. Recherche sur le titre=0|0|0=Traduit|1=Original
  22.  
  23. ***************************************************)
  24.  
  25. program Amazon_FR;
  26. uses
  27.   ScorEpioNCommonScript;
  28.  
  29. const
  30.   VersionScript = '11 du 23/05/2005';
  31.   urlDomain = 'amazon.';
  32.   NomScript = 'AMAZON.FR (IMAGE ONLY)';
  33.   timetosleep = 500;
  34.  
  35. var
  36.   MovieName, Address : string;
  37.   i, compteur, premiereExecution: Integer;
  38.   listeResultat: TStringList;
  39.  
  40. //------------------------------------------------------------------------------
  41. // RECUPERE GRANDE IMAGE AMAZON.FR
  42. //------------------------------------------------------------------------------
  43.  
  44. procedure imageAmazon(title : String);
  45. var
  46.   adresseRecherche, Line : String;
  47.   StartPos: Integer;
  48. begin
  49.   PickTreeClear;
  50.   adresseRecherche := 'http://www.amazon.fr/exec/obidos/search-handle-url/index=dvd-fr&field-keywords='+UrlEncode(title);
  51.   Line := GetPage(adresseRecherche);
  52.   if pos('satisfaisante pour votre recherche sur', Line) > 0 then
  53.   begin
  54.     exit;
  55.   end else
  56.   if (pos('Sur ce DVD', Line) > 0) or (pos('Amazon.fr : DVD:', Line) > 0) then
  57.   begin
  58.       StartPos := pos('<b class="sans">', Line);
  59.       delete(Line, 1, StartPos-1);
  60.       if CanSetPicture then
  61.             GetPicture(recupImage(Line));
  62.   end else
  63.   if pos('résultats au total pour', Line) > 0 then
  64.   begin
  65.       StartPos := pos('résultats au total pour', Line);
  66.       delete(Line, 1, StartPos);
  67.       recupAmazon(Line, title);
  68.   end;
  69. end;
  70.  
  71. //------------------------------------------------------------------------------
  72. // CREATION DE LA LISTE DE RESULTAT
  73. //------------------------------------------------------------------------------
  74.  
  75. procedure recupAmazon(Line, title : String);
  76. var
  77.    StartPos: Integer;
  78.    couple, titre, adresse : String;
  79.  
  80. begin
  81.   listeResultat := TStringList.Create;
  82.   StartPos := pos('/exec/obidos/ASIN/', Line);
  83.   repeat
  84. {*********************** Boucle DEBUT ***********************}
  85.      StartPos := pos('/exec/obidos/ASIN/', Line);
  86.      delete(Line, 1, StartPos+length('/exec/obidos/ASIN/')-1);
  87. {*********************** Boucle DEBUT ***********************}
  88. //ajoute les films
  89.      listeResultat.Add(recupTitle(Line)+'|'+recupImage(Line));
  90. {*********************** Boucle FIN ***********************}
  91.      StartPos := pos('<a href=/exec/obidos/ASIN/', Line);
  92.      delete(Line, 1, StartPos+length('<a href=/exec/obidos/ASIN/')-1);
  93.      StartPos := pos('/exec/obidos/ASIN/', Line);
  94. {*********************** Boucle FIN ***********************}
  95.   until (StartPos = 0);
  96.  
  97.   if (GetOption('Type de Lancement') = 0) or (GetOption('Type de Lancement') = 1) then
  98.   begin
  99.    PickTreeAdd('Films trouvΘs pour ' + title + ' :', '');
  100.    for i:=0 to listeResultat.Count-1 do
  101.    begin
  102.      couple := listeResultat.GetString(i);
  103.      titre := copy(couple,0,pos('|',couple)-1);
  104.      adresse := copy(couple,pos('|',couple)+1,length(couple)-1);
  105.      PickTreeAdd(titre , adresse);
  106.    end;
  107.  
  108.    if (PickTreeExec(Address)=true) then
  109.    begin
  110.        if CanSetPicture then
  111.             GetPicture(Address);
  112.    end;
  113.  
  114.   end else if (GetOption('Type de Lancement') = 2) then
  115.   begin
  116.       trouveTitle(title);
  117.   end;
  118. end;
  119.  
  120.  
  121. //------------------------------------------------------------------------------
  122. // RECUPERE L'ADRESSE DE L'IMAGE
  123. //------------------------------------------------------------------------------
  124.  
  125. function recupImage(Line : String) : String;
  126. var
  127.    ImageAddress : String;
  128.    StartPos: Integer;
  129. begin
  130.      StartPos := pos('http://images-eu.amazon.com/images/P/', Line);
  131.      delete(Line, 1, StartPos-1);
  132.      ImageAddress := copy(Line, 0, pos('"', Line) - 1);
  133.      ImageAddress := StringReplace(ImageAddress, 'THUMBZZZ', 'LZZZZZZZ');
  134.      result := ImageAddress;
  135. end;
  136.  
  137. //------------------------------------------------------------------------------
  138. // RECUPERE LE TITRE
  139. //------------------------------------------------------------------------------
  140.  
  141. function recupTitle(Line : String) : String;
  142. var
  143.    title : String;
  144.    StartPos: Integer;
  145. begin
  146.      StartPos := pos('<b>', Line);
  147.      delete(Line, 1, StartPos-1);
  148.      title := copy(Line, 1, pos('</b></a>', Line)-1);
  149.      HTMLRemoveTags(title);
  150.      title := StringReplace(title, #13#10, '');
  151.      result := title;
  152. end;
  153.  
  154. //------------------------------------------------------------------------------
  155. // SUPPRIME LES ACCENTS
  156. //------------------------------------------------------------------------------
  157.  
  158. function supprimeAccents(NomFilm : String) : String;
  159. begin
  160.      NomFilm := supprimeLesAccents(NomFilm);
  161.      delete(NomFilm, pos(' - ',NomFilm), length(NomFilm));
  162.      if (pos(', ',NomFilm) > 0) then
  163.         delete(NomFilm, 1, pos(', ',NomFilm)+1);
  164.      if (pos('(',NomFilm) > 0) then
  165.         delete(NomFilm, pos('(',NomFilm), length(NomFilm));
  166.      if (pos(':',NomFilm) > 0) then
  167.         delete(NomFilm, pos(':',NomFilm), length(NomFilm));
  168.      result := trim(NomFilm);
  169. end;
  170.  
  171. //------------------------------------------------------------------------------
  172. // COMPARE LE TITRE PASSE ET LE TITRE TROUVE
  173. //------------------------------------------------------------------------------
  174.  
  175. function compareTitle(titleAllo, title : String) : String;
  176. begin
  177.      title := supprimeAccents(trim(AnsiLowerCase(title)));
  178.      titleAllo := supprimeAccents(trim(AnsiLowerCase(titleAllo)));
  179.      if (title = titleAllo) then
  180.      begin
  181.        result := 'OK';
  182.      end else
  183.      begin
  184.        result := 'KO';
  185.      end;
  186. end;
  187.  
  188. //------------------------------------------------------------------------------
  189. // TROUVE LE BON TITRE SI LE PREMIER N'EST PAS LE BON
  190. //------------------------------------------------------------------------------
  191.  
  192. procedure trouveTitle(title : String);
  193. var
  194.    oK, couple, titre, adresse : String;
  195. begin
  196.    for i:=0 to listeResultat.Count-1 do
  197.    begin
  198.      couple := listeResultat.GetString(i);
  199.      titre := copy(couple,0,pos('|',couple)-1);
  200.      adresse := copy(couple,pos('|',couple)+1,length(couple)-1);
  201.      oK := compareTitle(title,titre);
  202.      if oK = 'OK' then
  203.      begin
  204.        GetPicture(adresse);
  205.        exit;
  206.      end;
  207.    end;
  208.    listeResultat.Free;
  209.  
  210. end;
  211.  
  212. //------------------------------------------------------------------------------
  213. // PROGRAMME PRINCIPAL
  214. //------------------------------------------------------------------------------
  215.  
  216. begin
  217.   if CheckVersion(3,5,0) then
  218.   begin
  219.     if GetOption('Mise α jour') = 0 then
  220.     begin
  221.        execMenuMAJ(VersionScript,NomScript);
  222.        exit;
  223.     end;
  224.     MovieName := recupTitreRecherche(GetOption('Recherche sur le titre'));
  225.     if (GetOption('Type de Lancement') = 0) then
  226.     begin
  227.       if Input(NomScript+' by ScorEpioN', 'Entrez le titre du film :', MovieName) then
  228.       begin
  229.         imageAmazon(MovieName);
  230.       end;
  231.     end else
  232.     begin
  233.       if (premiereExecution = 0) then
  234.       begin
  235.           premiereExecution := -1;
  236.           if (ShowConfirmation('Vous allez executer le script sans confirmation, cliquer sur ''''OUI'''' pour continuer') = True) then
  237.           begin
  238.             imageAmazon(MovieName);
  239.           end else
  240.             exit;
  241.       end else
  242.       begin
  243.           imageAmazon(MovieName);
  244.       end;
  245.     end;
  246.   end else
  247.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.5.0)');
  248. end.
  249.